Today you will
Build an app with its own database for a real use, and show it to the class.
- Pick a real project and plan it.
- Build it step by step with
project_dband Streamlit, testing every step. - Show it to the class: what it does, how it works, and one problem you solved.
- Give and receive useful feedback.
Deep dive A: pick your project
Your final project is an app with its own database, for a real use. Pick something you or someone you know would actually use. Every idea below follows the same pattern: a form to add records, a table to show them, and a report.
| Project | Who it's for | What each record saves | Report question |
|---|---|---|---|
| Club register | A sports club coach | name, phone, paid | Who still owes fees? |
| Homework tracker | A student | subject, task, due, done | What's not done yet? |
| Tuck shop stock | A school tuck shop | item, price, stock | What's running low? |
| Salon bookings | A hair salon | customer, day, time, service | Who's booked on Saturday? |
| Training log | Anyone who trains | date, activity, minutes | Which sessions were over 60 minutes? |
| Church or community group | A group leader | name, phone, team | Who is on the youth team? |
Deep dive B: project_db - a database for any project
shop_db only knows about a shop. For your own project there's project_db.py, which works for anything. You don't create tables: the first time you save a record, it makes the table for you.| Function | What it does |
|---|---|
project_db.add("members", {...}) | Saves one record. The record is a dictionary: field name, then value (Module 5). |
project_db.get_all("members") | Every record, as a list of dictionaries ([] if nothing is saved yet) |
project_db.query("SELECT ... WHERE ...") | Your own SELECT, exactly like Module 6 |
project_db.delete_all("members") | Throws the whole table away to start again. No undo! |
import project_db
project_db.add("members", {"name": "Jada", "phone": "555-0101", "paid": "Yes"})
project_db.add("members", {"name": "Marcus", "phone": "555-0102", "paid": "No"})
members = project_db.get_all("members")
print(len(members), "members")
for m in members:
print(f"{m['name']:<8} {m['phone']} paid: {m['paid']}")
unpaid = project_db.query("SELECT name FROM members WHERE paid = 'No'")
print("Still to pay:", unpaid)2 members
Jada 555-0101 paid: Yes
Marcus 555-0102 paid: No
Still to pay: [{'name': 'Marcus'}]Run it twice and you'll see 4 members: the database keeps everything, just like shop.db. The file is called project.db and sits next to your program, so you can open it in DB Browser.
Deep dive C: plan before you code
Ten minutes of planning saves an hour of fixing. Fill in this plan first. It's a Python file, so it runs too:
# my_plan.py - fill this in BEFORE you start building
project_name = "" # e.g. "Lions FC Register"
who_is_it_for = "" # e.g. "the coach of an under-13 football team"
table_name = "" # one word, e.g. "players"
fields = [] # what you save for each record, e.g. ["name", "age", "position"]
features = [ # 3 things your app will do
"", # e.g. "add a player with a form"
"", # e.g. "show all players in a table"
"", # e.g. "report: how many players in each position"
]
report_question = "" # the question your SELECT ... WHERE answers
print("Project:", project_name)
print("For:", who_is_it_for)
print("Saves", fields, "in the", table_name, "table")
for f in features:
print(" -", f)
print("Report:", report_question)Deep dive D: build in steps, test every step
Build it the same way as the Module 7 shop app: one step at a time, and run it after every step.
- Title and sidebar. Your project's name and what it's for.
- The form. Save a record with
project_db.add(). Check it in DB Browser. - The table. Show every record with
get_all()andst.dataframe(). - The report. A
st.metricor a chart, plus yourSELECT ... WHEREquestion. - Polish. Comments, clear names, one function of your own (Module 5B), helpful messages.
| Test | Try this | It should... |
|---|---|---|
| Empty | Open the app before saving anything | Show a friendly message, not crash |
| Bad input | Save with an empty name | Show a warning, not save |
| Lots of data | Add 10 records | Still show everything clearly |
| Close and reopen | Stop the app, run it again | Still have all the records |
| A friend | Let a classmate use it without help | Make sense to them |
Deep dive E: the showcase
Each project gets a 3-minute demo:
- What it does and who it's for (30 seconds)
- Show it working: add a record, show the table, show the report (90 seconds)
- How it works: point at one part of your code (30 seconds)
- One problem you solved, and how (30 seconds)
Then the class gives feedback: two stars and a wish. Two things that were good, and one thing you'd add or change.
1. The project template
A working starting point: a club register. Put it in a folder with project_db.py, run streamlit run project_template.py, then change it to fit your project.
# project_template.py - Module 8 final project starter: a club register
# Run it with: streamlit run project_template.py (project_db.py in the same folder)
#
# Make it YOURS: change the title, the table name ("members") and the fields
# in the form and in the add() line to fit your own project.
import streamlit as st
import project_db
st.sidebar.title("My Club Register") # your project's name
st.sidebar.write("Keeps track of members and fees.") # what it's for
st.title("My Club Register")
# ---- 1. a form to add a record ----
st.header("Add a member")
with st.form("add_member"):
name = st.text_input("Name")
phone = st.text_input("Phone")
paid = st.checkbox("Fees paid")
saved = st.form_submit_button("Save")
if saved:
if name.strip() == "":
st.warning("Please type a name.")
else:
if paid:
status = "Yes"
else:
status = "No"
project_db.add("members", {"name": name.strip(), "phone": phone, "paid": status})
st.success(f"Saved {name.strip()}")
# ---- 2. a table of everything saved ----
members = project_db.get_all("members")
st.header("Members")
if members:
st.dataframe(members)
else:
st.info("No members yet - add one above.")
# ---- 3. a report ----
st.header("Report")
if members:
paid_count = 0
for m in members:
if m["paid"] == "Yes":
paid_count += 1
st.metric("Members", len(members))
st.metric("Fees paid", paid_count)
st.bar_chart([{"fees": "Paid", "members": paid_count},
{"fees": "Not paid", "members": len(members) - paid_count}],
x="fees", y="members")
unpaid = project_db.query("SELECT name, phone FROM members WHERE paid = 'No'")
for m in unpaid:
st.warning(f"{m['name']} still owes fees - call {m['phone']}")See the browser. Before anything is saved:
No members yet - add one above. (blue)
Add Jada, 555-0101, tick Fees paid, Save: Saved Jada
Add Marcus, 555-0102, leave it unticked, Save: Saved Marcus
Members: a table with both
Report: Members 2 Fees paid 1 a bar chart: Paid 1, Not paid 1
Marcus still owes fees - call 555-0102 (yellow)
Save with an empty name: Please type a name.Practice: project steps
Final project (40%)
An app with its own database, for a real use. Marked out of 40:
| Part | Marks | What we look for |
|---|---|---|
| It works | 10 | Runs, and does the 3 features in your plan |
| Database | 10 | Saves records with project_db.add(), shows them with get_all(), and answers one question with SELECT ... WHERE |
| App | 8 | A form to add data, a table, and a metric or chart |
| Code quality | 6 | Clear names, comments, and at least one function of your own (Module 5B) |
| Demo | 6 | What it does, how it works, one problem solved |
Submit your project folder zipped: your .py files, project_db.py and project.db, plus your demo video if you are online.
What's next?
You've built a real app with its own database. Here's where you can go from here:
- Level 2: Python Foundations. Git, error handling with try/except, writing your own modules (like project_db.py), classes and objects, testing, APIs, and databases in depth: CREATE TABLE, updating records and joining tables.
- Then pick a specialty: Data Analytics, Apps, SQL and databases, or Robotics.
Your mission today
Finish your project and show it to everyone.
Your showcase checklist
Run it to print your checklist, then tick each item.
# Module 8 - Showcase checklist (run it to print your checklist)
checklist = [
"My project works when I press RUN",
"I used a loop",
"I used an if",
"I made my own function",
"I can explain one line of my code",
"I fixed a bug and can say how",
]
for number, item in enumerate(checklist, start=1):
print(number, "[ ]", item)Challenges
Try one at a time. Change the code, run it, and watch.